﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Owin;
using Microsoft.Owin.FileSystems;
using Microsoft.Owin.StaticFiles;
using Owin;

namespace nwrole.toolbox.sync.ConfigModule
{
    public class WebPipeline
    {
        public void Configuration(IAppBuilder appBuilder)
        {
            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            appBuilder.UseFileServer(new FileServerOptions()
            {
                FileSystem = new PhysicalFileSystem("../../static"),
                RequestPath = new PathString("/static")
            });

            appBuilder.UseWebApi(config);
            appBuilder.UseNancy(options => options.Bootstrapper = new NancyBootstrapper());
        }
    }
}
